var express = require("express");
var router = express.Router();
let {TestPaperModel} = require("../models/testPaperModel") //导入模型
let {TestModel} = require("../models/testsModel")
let {ErrModel} = require("../models/errModel")

/* GET users listing. */

//获取题目
router.get("/GetTestPaperFind", async (req, res, next)=> {
    let result = await TestModel.find().populate('typeId').populate('exercisesId');
    if (result) {
      res.send({
        code: 200,
        obj: result,
      });
    }
  
});

//获取错题库
router.get("/testPaperErr", async (req, res, next)=> {
  let result = await ErrModel.find().populate('exerciseId').populate('studentId');
  if (result) {
    res.send({
      code: 200,
      obj: result,
    });
  }

});

//新增错题
router.post("/CreatTestPaperErr", async (req, res, next)=> {
  console.log(req.body)
  let result = await ErrModel.create(req.body)
  if (result) {
    res.send({
      code: 200,
      obj: result,
    });
  }

});

module.exports = router;
